package com.wmx.main;

import com.wmx.entity.MyCallable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author:wmx 2025-03-10 19:19
 * 1、功能:
 * 2、参数{
 * <p>
 * <p>
 * }
 **/
public class entrance {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<Integer> futureTask1 = new FutureTask<>( new MyCallable(1,100));
        FutureTask<Integer> futureTask2 = new FutureTask<>( new MyCallable(101,900));
        FutureTask<Integer> futureTask3 = new FutureTask<>( new MyCallable(901,1000));

        Thread thread1 = new Thread(futureTask1);
        Thread thread2 = new Thread(futureTask2);
        Thread thread3 = new Thread(futureTask3);
        thread1.start();
        thread1.join();
        thread2.start();
        thread2.join();
        thread3.start();
        thread3.join();
        System.out.println("线程1的和:"+futureTask1.get());
        System.out.println("线程2的和:"+futureTask2.get());
        System.out.println("线程3的和:"+futureTask3.get());
        System.out.println("线程的和:"+futureTask1.get() + futureTask2.get() + futureTask3.get() );



    }
}
